<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>添加公告</title>
		<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"/>
		<style type="text/css">
			.box{
				padding: 20px 80px 20px 80px;
				width: 50%;
				
			}
			button,a,input,textarea{
				
			}
			*{
				cursor: pointer;
				
			}
			
		</style>
	</head>
	<body>
		
		
		<div class="box">
			
			<ol class="breadcrumb">
			  <li><a href="#">公告</a></li>
			  <li><a href="#">安卓</a></li>
			  <li class="active">新增公告</li>
			</ol>
			<form id="form1" action="/Notice/noticeController/addNotice" class="">
			  <div class="form-group">
			    <label for="n_title">标题</label><span style="color: red;">&nbsp;(必填)</span>
			    <input type="email" class="form-control" id="n_title" name="n_title" placeholder="标题">
			  </div>
			  <div class="form-group">
			    <label for="n_content">内容</label><span style="color: red;">&nbsp;(必填)</span>
			    <textarea type="text" class="form-control" id="n_content" name="n_content" placeholder="内容"></textarea>
			  </div>
			  <div class="form-group">
			  	<input type="hidden" name="n_create_date" id="n_create_date" value="" />
			    <label for="n_release_date">发布时间</label><span style="color: red;">&nbsp;(必填)</span>
			    <input type="date" class="form-control" id="n_release_date" name="n_release_date" placeholder="发布时间">
			  </div>
			  
			  <div class="form-group">
			    <label for="version_number">版本号</label><span style="color: red;">&nbsp;(必填)</span>
			    <input type="text" class="form-control" id="version_number" name="version_number" placeholder="版本号">
			  </div>
			 
			  
			  <button id="submit" type="button" class="btn btn-success">提交</button>
			</form>
		</div>
		
	</body>
	
	<script src="../js/jquery-2.1.4.min.js"></script>
	<script src="js/util.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(document).ready(ready);
		
		
		//页面载入需要的执行的动作
		function ready(){
			$("#n_create_date").val(getNowFormatDate());
		}
		
		$(document).on("click","#submit",addNotice);
		
		//请求数据到服务端
		function addNotice(){
			
			var n_title = $("#n_title").val();
			var n_content = $("#n_content").val();
			var n_release_date = $("#n_release_date").val();
			var n_create_date = $("#n_create_date").val();
			var version_number = $("#version_number").val();
			if(isNull(n_title)){alert("标题不可为空");return;}
			if(isNull(n_content)){alert("内容不可为空");return;}
			if(isNull(n_release_date)){alert("发布时间不可为空");return;}
			if(isNull(version_number)){alert("版本号不可为空");return;}
			
			$.ajax({
				url:"/Notice/noticeController/addNotice",
				type:"POST",
				data:{n_title:n_title,n_content:n_content,n_release_date:n_release_date,n_create_date:n_create_date,version_number:version_number},
				success:function(json){
					alert(json.success);
				}
			});
		}
		
		
		
		
		
	</script>
</html>
